<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style/css/main.css" rel="stylesheet" type="text/css" />
<script src="style/js/jquery.js" type="text/javascript"></script>
<script src="style/js/main.js" type="text/javascript"></script>
<title>admin_main</title>
</head>

<body>
<div class="main">
<?php
if($edit)
{
?>
<table id="main_table">
<form action="admin_main.php" method="post">
<input type="hidden" name="id" value="<?php echo $edit;?>" />
    	<tr>
        	<th colspan="2" align="left"><?php echo $title;?></th>
        </tr>
        <tr>
        	<td align="center">姓名：</td>
        	<td align="left" class="indent">
            <input type="text" name="username" class="midtext" value="<?php echo $user_info['username'];?>" /></td>
        </tr>
        <tr>
        	<td align="center">管理员等级：</td>
        	<td align="left" class="indent">
            <select name="typeid">
            	<?php
                foreach($rank as $val)
                {
                ?>
                	<option value="<?php echo $val['typeid'];?>" 
                    <?php echo $user_info['typeid'] == $val['typeid'] ? 'selected="selected"': '';?>>
                    <?php echo $val['name'];?></option>
            	<?php
                }
                ?>
            </select>
            </td>
        </tr>
        <tr>
        	<td align="center">性别：</td>
        	<td align="left" class="indent">
                <label><input type="radio" name="sex" value="男" <?php echo $user_info['sex'] == '男' ? 'checked="checked"' : '';?>/>男&nbsp;&nbsp;</label>
            	<label><input type="radio" name="sex" value="女" <?php echo $user_info['sex'] == '女' ? 'checked="checked"' : '';?>/>女&nbsp;&nbsp;</label>
            	<label><input type="radio" name="sex" value="保密" <?php echo $user_info['sex'] == '保密' ? 'checked="checked"' : '';?>/>保密&nbsp;</label>
            </td>
        </tr>
        <tr>
        	<td align="center">email：</td>
        	<td align="left" class="indent">
            <input type="text" name="email" class="midtext" value="<?php echo $user_info['email'];?>" /></td>
        </tr>
        <tr>
        	<td>&nbsp;</td>
        	<td align="left" class="indent">
            	<input type="submit" class="btn3" name="member_sub" value="更改" />
            	<input type="reset" class="btn3" value="重置" />
                <input type="button" class="btn3" onclick="history.go(-1)" value="返回" />
            </td>
        </tr>
</form>
</table>
<?php
}
else if($add)
{
?>
<table id="main_table">
<form action="admin_main.php" method="post">
    <tr>
        <th colspan="10" align="left"><?php echo $title;?></th>
    </tr>
    <tr>
        <td align="center" width="30%">登录名：</td>
        <td align="left" width="70%" class="indent"><input type="text" name="userid" class="midtext" /></td>
    </tr>
    <tr>
        <td align="center" width="30%">姓名：</td>
        <td align="left" width="70%" class="indent"><input type="text" name="username" class="midtext" /></td>
    </tr>
    <tr>
        <td align="center" width="30%">性别：</td>
        <td align="left" width="70%" class="indent">
        <input type="radio" name="sex" value="男"  />男&nbsp;&nbsp;
        <input type="radio" name="sex" value="女"  />女&nbsp;&nbsp;
        <input type="radio" name="sex" value="保密"  checked="checked" />保密
        </td>
    </tr>
    <tr>
        <td align="center" width="30%">密码：</td>
        <td align="left" width="70%" class="indent"><input type="password" name="pwd1" class="midtext" /></td>
    </tr>
    <tr>
        <td align="center" width="30%">再次输入密码：</td>
        <td align="left" width="70%" class="indent"><input type="password" name="pwd2" class="midtext" /></td>
    </tr>
    <tr>
        <td align="center" width="30%">email：</td>
        <td align="left" width="70%" class="indent"><input type="text" name="email" class="midtext" /></td>
    </tr>
    <tr>
        <td align="center" width="30%">用户类型：</td>
        <td align="left" width="70%" class="indent">
        <select name="type">
        <?php
        foreach($rank as $val)
        {
        ?>
        	<option value="<?php echo $val['typeid'];?>"><?php echo $val['name'];?></option>
        <?php
        }
        ?>
        </select>
        </td>
    </tr>
        <tr>
        <td align="center"></td>
        <td align="left" class="indent">
        <input type="submit" name="sub_add_admin" class="btn" value="增加" />
        <input type="reset" class="btn" value="重置" />
        <input type="button" class="btn" onclick="history.go(-1)" value="返回" />
        </td>
    </tr>
    </form>
</table>
<?php
}
else
{
?>
	<table id="main_table">
    	<tr>
        	<th colspan="10" align="left"><?php echo $title;?></th>
        </tr>
    	<tr>
        	<td align="center" width="8%">ID</td>
        	<td align="center" width="12%">登录名</td>
        	<td align="center" width="12%">姓名</td>
        	<td align="center" width="10%">管理员等级</td>
        	<td align="center" width="6%">性别</td>
        	<td align="center" width="14%">email</td>
        	<td align="center" width="13%">上次登录时间</td>
        	<td align="center" width="10%">上次登录IP</td>
        	<td align="center" width="15%">操作</td>
        </tr>
<?php
foreach($list as $v)
{
?>
        <tr>
        	<td align="center"><?php echo $v['id'];?></td>
        	<td align="center"><?php echo $v['userid'];?></td>
        	<td align="center"><?php echo $v['username'];?></td>
        	<td align="center"><?php echo $v['name'];?></td>
        	<td align="center"><?php echo $v['sex'];?></td>
        	<td align="center"><?php echo $v['email'];?></td>
        	<td align="center"><?php echo $v['lasttime'];?></td>
        	<td align="center"><?php echo $v['lastip'];?></td>
        	<td align="center">
            <?php
            if($v['id'] != 1)
            {
            ?>
            <a href="admin_main.php?action=edit&id=<?php echo $v['id'];?>" class="edit_img">编辑</a>
            <?php 
           		if($_SESSION['id'] == 1)
            	{
            		echo '<a onclick="return confirm(\'你确定要删除此管理员吗？删除无法恢复！\');" href="admin_main.php?action=del&id=' . $v['id'] . '" class="del_img">删除</a>';
            	}
            }
            else
            {
            	echo '<a href="#">系统管理员，禁止操作</a>';
           	}
            ?>
            </td>
        </tr>
<?php
}
foreach($list as $v)
{
	if($v['id'] == 1)
    {
    	echo '<tr><td align="center" colspan="9">';
        echo '<input type="button" class="btn2" value="增加管理员" onclick="location.href=\'admin_main.php?action=add\'" /></td></tr>';
    }
}
?>
</table>
<?php
}
?>
</div>
<?php echo $copyright;?>
</body>
</html>
